﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Chowpoo.Sql;

namespace CourseSystem.Core.Entities
{
    [Table(Name = "CourseComment")]
    public class CourseCommentInfo : IDetach
    {
        public CourseCommentInfo()
        {
            Detach();
        }
        #region Model
        private int _id;
        private int _commenttype = 0;
        private string _comment = "";
        private DateTime _commenttime = DateTime.Now;
        private int _reviewertype = 0;
        private int _reviewerid = 0;
        private string _reviewername = "";
        private int _teacherid = 0;
        private string _teachername = "";
        private int _rank = 0;


        private EntityRef<StudentInfo> _studentInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_studentInfo", ThisKey = "ReviewerId", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public StudentInfo StudentInfo
        {
            get { return _studentInfo.Entity; }
            set { _studentInfo.Entity = value; }
        }

        private EntityRef<TeacherInfo> _teacherInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_teacherInfo", ThisKey = "TeacherId", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public TeacherInfo TeacherInfo
        {
            get { return _teacherInfo.Entity; }
            set { _teacherInfo.Entity = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Column(IsDbGenerated = true, IsPrimaryKey = true, IsVersion = true)]
        public int Id
        {
            set { _id = value; }
            get { return _id; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int CommentType
        {
            set { _commenttype = value; }
            get { return _commenttype; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public string Comment
        {
            set { _comment = value; }
            get { return _comment; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public DateTime CommentTime
        {
            set { _commenttime = value; }
            get { return _commenttime; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int ReviewerType
        {
            set { _reviewertype = value; }
            get { return _reviewertype; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int ReviewerId
        {
            set { _reviewerid = value; }
            get { return _reviewerid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public string ReviewerName
        {
            set { _reviewername = value; }
            get { return _reviewername; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int TeacherId
        {
            set { _teacherid = value; }
            get { return _teacherid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public string TeacherName
        {
            set { _teachername = value; }
            get { return _teachername; }
        }
        /// <summary>
        /// 
        /// </summary>
        [Column]
        public int Rank
        {
            set { _rank = value; }
            get { return _rank; }
        }
        #endregion Model

        public void Detach()
        {
            this._studentInfo = default(EntityRef<StudentInfo>);
            this._teacherInfo = default(EntityRef<TeacherInfo>);
        }
    }
}
